<template>
  <confirm-dialog
    :title="this.$t('order.confirmFail')"
    :visible="visible"
    :loading="loading"
    @handleClose="handleClose"
    width="25%"
  >
    <template slot="content">
      <p>以下订单操作失败</p>
      <ul v-if="Array.isArray(data)">
        <li v-for="(item, index) in data" :key="index">{{ item.orderId }} {{ item.errorMsg }}</li>
      </ul>
      <ul v-if="!Array.isArray(data)">
        <li>{{ data.orderId }} {{ data.errorMsg }}</li>
      </ul>
    </template>
    <template slot="footer">
      <el-button :disabled="loading" type="primary" @click="handleClose">{{
        $t("common.confirm")
      }}</el-button>
    </template>
  </confirm-dialog>
</template>
<script lang="ts">
import Vue from "vue";
import FormDialop from "../../../../components/Dialog/formDialog.vue";
import ConfirmDialog from "../../../../components/Dialog/confirmDialog.vue";
export default Vue.extend({
  components: {
    FormDialop,
    ConfirmDialog,
  },
  props: {
    submitMethod: {
      type: Function,
      default() {
        return (formData: any) => Promise.resolve();
      },
    },
  },
  data() {
    return {
      title: "",
      visible: false,
      loading: false,
      data: [],
      content: '',
    };
  },
  methods: {
    handleClose() {
      this.visible = false;
      this.loading = false;
    },
    async init(obj: any) {
      const errMsgDetails: any = [];
      (obj as any).forEach((item: any) => {
        const errMsgDetail = {};
        (errMsgDetail as any).orderId = item.data.info.orderId;
        (errMsgDetail as any).errorMsg = item.message;
        errMsgDetails.push(errMsgDetail);
      })
      this.visible = true;
      (this as any).data = (errMsgDetails as any);
    },
    submit() {
      this.loading = true;
      let data: any = [];
    },
  },
});
</script>
